package com.cristina.attention.entity.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.cristina.attention.entity.Friend;
import com.cristina.attention.entity.Group;
import com.cristina.attention.entity.User;
import lombok.Data;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import java.util.List;
import java.util.Set;

/**
 * @author by Attention
 * @Classname UserVo
 * @Date 2021/12/5
 */
@Data
public class UserVo extends User {

    /**
     * 我添加的好友, 所有origin是我的id
     * 懒加载, 一对多关系
     */
    @JoinColumn(name = "originId")
    @LazyCollection(LazyCollectionOption.EXTRA)
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Friend> friends;

    /**
     * 我添加的群聊
     */
    @TableField(exist = false)
    private List<Group> groups;
}
